package com.ql.dao;

import com.ql.domain.HomeWorkSetting;
import com.ql.domain.response.JsonResult;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface HomeWorkSettingDao {
    @Select({
            "<script>",
            "select",
            "*",
            "from homework_setting",
            "where  sectionId in",
            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "order by sorting",
            "</script>"
    })
    List<HomeWorkSetting> findAll(@Param("ids") List<Integer> ids);

    @Select("select * from homework_setting where logo=#{logo}")
    HomeWorkSetting findOneByLogo(String logo);

    /**
     * 新增
     *
     * @param homeWorkSetting
     */
    @Insert("insert into homework_setting values(#{ID},#{name},#{type},#{sorting},#{warningRules},#{logo},#{pileNum},#{speed},#{drillingSpeed},#{averageAsh},#{largestSlope},#{beginDepth},#{mixingDepth},#{emptyDepth},#{waterCementRatio},#{sectionId})")
    void add(HomeWorkSetting homeWorkSetting);

    /**
     * 更新
     *
     * @param homeWorkSetting
     */
    void update(HomeWorkSetting homeWorkSetting);

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @Delete("delete from homework_setting where id = #{id}")
    void del(String id);
}
